# -*- coding:utf-8 -*-
"""
系统设置项模型
"""
from django.db import models
import django.utils.timezone as timezone


class SysParam(models.Model):
    """
    系统参数表
    """
    # 参数编号
    param_value = models.IntegerField(
        primary_key=True,
        verbose_name='参数编号', blank=False)
    # 参数名称
    param_name = models.CharField(
        max_length=10, verbose_name='参数名称', blank=False)
    # 参数说明
    param_remark = models.CharField(max_length=20, verbose_name='参数说明')

    class Meta:
        verbose_name = '系统参数'
        verbose_name_plural = '系统参数'
        db_table = 'setting_sys_param'

    def __str__(self):
        return '{0},{1}'.format(self.param_value, self.param_name)

    def get_name(self):
        return self.param_name


class OrgUnit(models.Model):
    """
    组织机构信息模型
    """
    create_time = models.DateTimeField(
        blank=False, null=False, default=timezone.now, verbose_name='创建日期')
    create_id = models.IntegerField(
        blank=True, null=True, verbose_name='创建ID')
    last_update = models.DateTimeField(blank=True, null=True)
    last_update_id = models.IntegerField(blank=True, null=True)
    update_count = models.IntegerField(blank=True, null=True)
    parent_unit = models.IntegerField(blank=True, null=True)
    unit_code = models.CharField(max_length=6, blank=True, null=True)
    unit_name = models.CharField(max_length=40, blank=False, null=False)
    short_name = models.CharField(max_length=20, blank=True, null=True)
    address = models.CharField(max_length=1000, blank=True, null=True)
    tel = models.CharField(max_length=20, blank=True, null=True)
    postal_code = models.CharField(max_length=6, blank=True, null=True)
    email = models.CharField(max_length=255, blank=True, null=True)
    legal_person = models.CharField(max_length=12, blank=True, null=True)
    level = models.IntegerField(blank=True, null=True)
    status = models.IntegerField(default=1, blank=False, null=False)

    class Meta:
        verbose_name = '组织机构'
        verbose_name_plural = '组织机构'
        db_table = 'setting_org_unit'


class DptMt(models.Model):
    """
    部门
    """
    org_unit_id = models.IntegerField(blank=False, null=False)
    dptmt_name = models.CharField(max_length=40, blank=False, null=False)
    status = models.IntegerField(default=1, blank=False, null=False)

    class Meta:
        verbose_name = '部门'
        verbose_name_plural = '部门'
        db_table = 'setting_department'
